<?php
$req = array(
	"controller/controller.php",
	"model/database.php",
	"lib/fpdf.php",
	"lib/helvetica0.php",
	"view/gui.php"
);

foreach($req as $file){
	if(file_exists($file)){ require($file); }
	else{ print "REQUIRED FILE ERROR"; exit; }
}

session_start();

$url = !empty($_GET["url"]) ? $_GET["url"] : "pos";
$url = rtrim($url, "/");
$url = explode("/", $url);

$controller = "controller/".$url[0].".php";
if(!file_exists($controller)){
	header("Location: index.php?url=error/404/".implode("/", $url));
}

require($controller);

$controller = new $url[0]($url);
$controller->start();
?>